<template>
  <div>
    <table>
      <tr>
        <th>商品名</th>
        <th>描述</th>
        <th>价格</th>
      </tr>
      <tr v-for="a in all">
        <td>{{ a.name }}</td>
        <td>{{ a.desc }}</td>
        <td>{{ a.price }}</td>
      </tr>
    </table>

  </div>

</template>

<script>
    export default {
        name: "jian",
      data(){
          return{
            //检索关键字
            text:'',
            	  //商品列表
            all:[],
          }
      },
      mounted() {

	  	  //接收检索参数
	      var text = this.$route.query.text;
	      this.get_goodslist();

          //判断
      if(text.indexOf(' ')){

      text = text.split(" ");

      //格式转换
      text = JSON.stringify(text);

	  }

	  this.text = text;

      },
      methods:{
          	//获取商品
     get_goodslist:function(){

                     //请求后台接口
		  this.axios.get('http://127.0.0.1:8000/allgoods/',{params:{text:this.text}}).then((result)=>{

				console.log(this.text);


				this.all = result.data.data;



			});

	 },

      }
    }
</script>

<style scoped>

</style>
